package com.xisoft.base;

/**
 * @author xzh
 * @Date 2021/8/16
 * @description 表字段
 * 注意：本内容仅限于上海熙软科技有限公司内部，传阅，禁止外泄以及用于其他商业目的
 */
public class Column {

    /**
     * 忽略的公共字段名称
     */
//	public static final String ignoreColumns =
//		"status,checkTime,startTime,endTime,dataauth,saleOrgId,id,creatorId,createTime,lastEditTime,lastEditorId,deleted,deleteUserId,markDeletedTime,checked,checkerId";
    public static final String ignoreColumns = "";


    /**
     * 数据库名称
     */
    public String dName;

    /**
     * 对应vo中的列名
     */
    public String vName;

    /**
     * 备注
     */
    public String COMMENTS;
    /**
     * 备注
     */
    public String UNICODE_COMMENTS;
    /**
     * 数据里类型
     */
    public String DATA_TYPE;

    /**
     * 对应的java 类型 String BigDecimal Date Int
     */
    public String vType;

    /**
     * 对应的xml中 类型 1，java.math.BigDecimal 2，java.lang.String 3，java.util.Date
     */
    public String xmlType;

    /**
     * 是否为空 Y N
     */
    public String NULLABLE;

    /**
     * 数据长度
     */
    public String DATA_LENGTH;

    public boolean Primary;

    /**
     * 数据精度 NUMBER 类型中运到的比较多
     */
    public String DATA_PRECISION;

    /*数字小数点*/
    public String DATA_SCALE;

    /*数字最大值*/
    public String DATA_MAX;

    /*数字格式化*/
    public String DATA_FORMAT;

    public String getdName() {

        return dName;
    }

    public void setdName(String dName) {

        this.dName = dName;
    }

    public String getvName() {

        return vName;
    }

    public void setvName(String vName) {

        this.vName = vName;
    }

    public String getDATA_MAX() {

        return DATA_MAX;
    }


    public void setDATA_MAX(String dATA_MAX) {

        DATA_MAX = dATA_MAX;
    }


    public String getDATA_FORMAT() {

        return DATA_FORMAT;
    }


    public void setDATA_FORMAT(String dATA_FORMAT) {

        DATA_FORMAT = dATA_FORMAT;
    }

    public String getCOMMENTS() {

        return COMMENTS;
    }

    public void setCOMMENTS(String cOMMENTS) {

        COMMENTS = cOMMENTS;
    }

    public String getDATA_TYPE() {

        return DATA_TYPE;
    }

    public void setDATA_TYPE(String dATA_TYPE) {

        DATA_TYPE = dATA_TYPE;
    }

    public String getNULLABLE() {

        return NULLABLE;
    }

    public void setNULLABLE(String nULLABLE) {

        NULLABLE = nULLABLE;
    }

    public String getDATA_LENGTH() {

        return DATA_LENGTH;
    }

    public void setDATA_LENGTH(String dATA_LENGTH) {

        DATA_LENGTH = dATA_LENGTH;
    }

    public String getDATA_PRECISION() {

        return DATA_PRECISION;
    }

    public void setDATA_PRECISION(String dATA_PRECISION) {

        DATA_PRECISION = dATA_PRECISION;
    }

    public String getvType() {

        return vType;
    }

    public void setvType(String vType) {

        this.vType = vType;
    }

    public String getDATA_SCALE() {

        return DATA_SCALE;
    }


    public void setDATA_SCALE(String dATA_SCALE) {

        DATA_SCALE = dATA_SCALE;
    }

    public String getUNICODE_COMMENTS() {

        return UNICODE_COMMENTS;
    }


    public void setUNICODE_COMMENTS(String uNICODE_COMMENTS) {

        UNICODE_COMMENTS = uNICODE_COMMENTS;
    }

    public void setVtypeByDType() {

        if ("DATE".equals(this.DATA_TYPE)) {
            vType = "Date";
        } else if ("DATETIME".equals(this.DATA_TYPE)) {
            vType = "DateTime";
        } else if ("DECIMAL".equals(this.DATA_TYPE)) {
            vType = "double";
        } else if ("VARCHAR".equals(this.DATA_TYPE) || "VARCHAR2".equals(this.DATA_TYPE) || "CHAR".equals(this.DATA_TYPE) || "CLOB".equals(this.DATA_TYPE)
                || "NVARCHAR2".equals(this.DATA_TYPE) || "NCLOB".equals(this.DATA_TYPE)) {
            vType = "String";
        } else if ("INTEGER".equals(this.DATA_TYPE) || "INT".equals(this.DATA_TYPE)) {
            vType = "int";
        } else if ("NUMBER".equals(this.DATA_TYPE)) {
            vType = "double";
        } else if ("LONG".equals(this.DATA_TYPE)) {
            vType = "long";
        } else if ("BOOLEAN".equals(this.DATA_TYPE)) {
            vType = "boolean";
        } else if ("BLOB".equals(this.DATA_TYPE)) {
            vType = "java.sql.Blob";
        } else if ("FLOAT".equals(this.DATA_TYPE)) {
            vType = "float";
        }


    }

    /**
     * 根据数据库类型，来决定xml中的类型
     */
    public void setXmlTypeByDtype() {

//		if ("date".equals(this.DATA_TYPE)) {
//			xmlType = "java.util.Date";
//		} else if ("decimal".equals(this.DATA_TYPE)) {
//			xmlType = "java.math.BigDecimal";
//		} else if ("varchar".equals(this.DATA_TYPE) || "char".equals(this.DATA_TYPE)) {
//			xmlType = "java.lang.String";
//		} else if ("integer".equals(this.DATA_TYPE) || "int".equals(this.DATA_TYPE)) {
//			vType = "java.lang.Integer";
//		} else if ("long".equals(this.DATA_TYPE)) {
//			vType = "java.lang.Long";
//		} else if ("boolean".equals(this.DATA_TYPE)) {
//			vType = "java.lang.Boolean";
//		}

        if ("DATETIME".equals(this.DATA_TYPE)) {
            xmlType = "TIMESTAMP";
        } else if ("DATE".equals(this.DATA_TYPE)) {
            xmlType = "DATE";
        } else if ("DECIMAL".equals(this.DATA_TYPE)) {
            xmlType = "DECIMAL";
        } else if ("VARCHAR".equals(this.DATA_TYPE) || "CHAR".equals(this.DATA_TYPE) || "VARCHAR2".equals(this.DATA_TYPE)) {
            xmlType = "VARCHAR";
        } else if ("INTEGER".equals(this.DATA_TYPE) || "INT".equals(this.DATA_TYPE) || "NUMBER".equals(this.DATA_TYPE)) {
            xmlType = "INTEGER";
        } else if ("BOOLEAN".equals(this.DATA_TYPE)) {
            xmlType = "BOOLEAN";
        } else if ("BLOB".equals(this.DATA_TYPE)) {
            xmlType = "BLOB";
        } else if ("CLOB".equals(this.DATA_TYPE)) {
            xmlType = "CLOB";
        } else if ("FLOAT".equals(this.DATA_TYPE)) {
            xmlType = "FLOAT";
        } else if ("NVARCHAR2".equals(this.DATA_TYPE)) {
            xmlType = "NVARCHAR2";
        } else if ("NCLOB".equals(this.DATA_TYPE)) {
            xmlType = "NCLOB";
        }

    }

    /**
     * @return the xmlType
     */
    public String getXmlType() {

        return xmlType;
    }

    /**
     * @param xmlType the xmlType to set
     */
    public void setXmlType(String xmlType) {

        this.xmlType = xmlType;
    }

    public boolean isPrimary() {
        return Primary;
    }

    public void setPrimary(boolean primary) {
        Primary = primary;
    }


}
